import * as actions from '../actions/index';

// 对页面prop 数据进行管理
const initialState = {
  activities: [],
  currentPage: 1,
  isLoading: true,
};
const defaultAction = {
  type: 'doNothing',
};

export default function index(state = initialState, action = defaultAction) {
  switch (action.type) {
    case actions.RECEIVE_GROUP_ACTIVITIES:
      return {
        ...state,
        activities: action.data.list,
        total: action.data.amount,
        currentPage: action.data.currentPage,
        isLoading: false,
      };
    case actions.LOADING_LIST:
      return { ...state, isLoading: true };
    default:
      return state;
  }
}
